# -*- coding: utf-8 -*-
"""
@FileName：config.py
@Description：
@Author：锦沐Python
@Time：2024/8/24 17:27
"""
import os
from pathlib import Path

# 打包使用
# _current_path = Path(".").resolve() / "_internal"

_current_path = Path(".").resolve()
ICON = _current_path / "src" / "assest" / "icon.png"
END_PATH = _current_path / "src" / "assest" / "end.png"
FORWARD_PATH = _current_path / "src" / "assest" / "forward.png"
NEXT_PATH = _current_path / "src" / "assest" / "next.png"
PATH_PATH = _current_path / "src" / "assest" / "path.png"
PAUSE_PATH = _current_path / "src" / "assest" / "pause.png"
PLAY_PATH = _current_path / "src" / "assest" / "play.png"
START_PATH = _current_path / "src" / "assest" / "start.png"
SAVE_VIDEO_PATH = Path(".").resolve() / "save_video"


# 模式
VIDEO_PLAY = 2
VIDEO_RECORD = 4

# 窗口
WIN_SIZE = "900x600+5+5"
WIN_MIN_WIDTH = 700
WIN_MIN_HEUGHT = 500

# 注意，由于Ui图片是白色的，所以使用 黑色主题 才能看清 ui
# 主题  https://ttkbootstrap-zh.readthedocs.io/zh-cn/stable/themes/light/
# solar | darkly | superhero | cyborg | vapor |
THEME_STYLE = "cyborg"

# 按钮风格
BUTTON_STYLE = "Link.TButton"

# 更新速度 ms
UPDATE_TIME = 30

# 检查文件夹是否存在
if not os.path.exists(SAVE_VIDEO_PATH):
    # 如果文件夹不存在，则创建它
    os.makedirs(SAVE_VIDEO_PATH)
    print(f"文件夹 {SAVE_VIDEO_PATH} 已创建。")
else:
    print(f"文件夹 {SAVE_VIDEO_PATH} 已存在。")


# 装饰器
def mode_wrapper(mode):
    """
    限制执行函数，只有在模式对应时： mode 与 MainWindow的mode_state相同
    才执行被装饰函数
    :param mode: VIDEO_RECORD | VIDEO_PLAY
    :return:
    """
    def decorator(func):
        def wrapper(*args, **kwargs):
            # 获取类的 self.mode_state 参数
            if args[0].mode_state == mode:
                return func(*args, **kwargs)
            else:
                print(f"模式不匹配, 函数：{func.__name__}不执行")
        return wrapper
    return decorator

